package com.example.router;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class RouterActivityInfo {

    private static final String TAG = "RouterActivityInfo";

    private String category;
    private String title;
    private String descript;
    private Class cls;

    public RouterActivityInfo() {
    }

    public RouterActivityInfo(String category,String title, String descript, Class cls) {
        this.category = category;
        this.title = title;
        this.descript = descript;
        this.cls = cls;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescript() {
        return descript;
    }

    public void setDescript(String descript) {
        this.descript = descript;
    }

    public Class getCls() {
        return cls;
    }

    public void setCls(Class cls) {
        this.cls = cls;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public void startActivity(Bundle bundle, boolean hasBundle, int requestCode, boolean needRequestCode, Activity activity) {
        if (cls == null) {
            Log.d(TAG, "startTitle: " + title + " don't exist!!!");
            return;
        }

        Intent intent = new Intent(activity,cls);
        if (hasBundle) {
            intent.putExtras(bundle);
        }

        if (needRequestCode) {
            activity.startActivityForResult(intent,requestCode);
        } else {
            activity.startActivity(intent);
        }
    }
}
